package com.sxt.feign;

import com.sxt.feign.rpc.EurekaClientFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableFeignClients
@RestController
public class FeignClientApplication {

	@Autowired
	private EurekaClientFeign eurekaClientFeign;

	public static void main(String[] args) {
		SpringApplication.run(FeignClientApplication.class, args);
	}

	/**
	 * 远程调用eureka-client服务的info接口
	 * @return
	 */
	@GetMapping("/rpc/info")
	public String feignRpc() {
		String info = eurekaClientFeign.info();
		System.out.println(info);
		return  info;
	}

	/**
	 * 远程调用eureka-client服务的分页接口
	 * @return
	 */
	@GetMapping("/rpc/page")
	public String getPage() {
		String info = eurekaClientFeign.getPage(1,10);
		System.out.println(info);
		return  info;
	}

	@Bean
	public RestTemplate rest() {
		return new RestTemplate();
	}

}
